package cn.yearndr.zfsy.zfsy.controller;


import cn.yearndr.zfsy.zfsy.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

/**
 * 获取通过解析天气API返回天气数据JSON
 */
@Controller
public class WeatherController {

//    @Autowired
//    HttpRequestService httpRequestService;
    @Autowired
    WeatherService weatherService;



    /**
     * 通过百度的天气API获取天气信息并返回「百度所展示的天气信息来自中国天气的API」
     * @param ip
     * @return
     */
    @RequestMapping("/weather")
    public String  getWeatherByIP(String ip, Map<String,Object> map) throws IOException {
        map.put("weather",weatherService.getWeatherByIP(ip));
        return "weather";
    }

}
